﻿using System.Data;

namespace DAL
{
    public class Room_DAL : clsConnect
    {
        private static readonly clsConnect cls = new clsConnect();
        #region[Get-Data]
        public static DataTable GetRoom(string keywords)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@KEYWORDS", keywords);
            return cls.GetData("sp_tb_Room_Search");
        }
        public DataTable GetRoomWareHouse(int id)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Warehouse_Id", id);
            return cls.GetData("sp_tb_Room_Warehouse");
        }
        public DataTable GetRoomDetail_Edit(int id)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Room_Id", id);
            return cls.GetData("sp_tb_Room_Detail_Edit");
        }
        public static DataTable GetRoomFillter(int id)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Warehouse_Id", id);
            return cls.GetData("sp_tb_Room_Fillter");
        }
        #endregion

        #region[Insert-Update-Delete]
        public bool InsertRoom(ET.Room_ET data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Room_Alias", data.Room_Alias);
            cls.AddParameter("@Warehouse_Id", data.Warehouse_Id);
            cls.AddParameter("@Room_Name", data.Room_Name);
            cls.AddParameter("@Room_Tankage", data.Room_Tankage);
            cls.AddParameter("@Unit_Id", data.Unit_Id);
            cls.AddParameter("@Room_Note", data.Room_Note);
            return cls.ExecuteNonQuery("sp_tb_Room_Insert");
        }
        public bool UpdateRoom(ET.Room_ET data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Room_Id", data.Room_Id);
            cls.AddParameter("@Warehouse_Id", data.Warehouse_Id);
            cls.AddParameter("@Room_Alias", data.Room_Alias);
            cls.AddParameter("@Room_Name", data.Room_Name);
            cls.AddParameter("@Room_Tankage", data.Room_Tankage);
            cls.AddParameter("@Unit_Id", data.Unit_Id);
            cls.AddParameter("@Room_Note", data.Room_Note);
            return cls.ExecuteNonQuery("sp_tb_Room_Update");
        }
        public bool DeleteRoom(int id)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Room_Id", id);
            cls.ExecuteNonQuery("sp_tb_Room_Delete");
            return true;
        }
        #endregion

        #region[Search-Fillter]
        public DataTable Search(string keywords)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@KEYWORDS", keywords);
            return cls.GetData("sp_tb_Room_Search");
        }
        #endregion
    }
}